#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    ll l,r;
    cin >> l >>r;
    ll ans=0;
    for(ll i=l;i<=r;i++)
    {
        ll x=i;
        while(x)
        {
            if(x%10==2)
            {
                ans++;
            }
            x /= 10;
        }
    }
    cout << ans;
}
// 64 位输出请用 printf("%lld")